package com.kung.qvs.ui.main.fragment;

import android.bluetooth.BluetoothDevice;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class BleDeviceItemViewModel extends ItemViewModel<BleDeviceViewModel> {
    public ObservableField<BluetoothDevice> entity = new ObservableField<>();

    public BleDeviceItemViewModel(@NonNull BleDeviceViewModel viewModel, BluetoothDevice entity) {
        super(viewModel);
        this.entity.set(entity);
    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            //这里可以通过一个标识,做出判断，已达到跳入不同界面的逻辑
//            viewModel.onToPageRecycleDetailCommand.execute(entity.get().getEquipmentValue());
//            Ble<BleDevice> ble = Ble.getInstance();
//            if (ble.isScanning()) {
//                ble.stopScan();
//            }
//            BleManager.getInstance().cancelScan();
            viewModel.onConnectBle(entity.get());
        }
    });
}
